package com.lagou.edu.service.impl;

import com.lagou.edu.EmailService;
import com.lagou.edu.util.EmailUtil;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Value;

@Service
public class EmailServiceImpl implements EmailService {

    @Override
    public Boolean sendEmail(String email, String code) {

        try {
            //这里邮箱地址和授权码暂时写死，安全性考虑没有放到配置文件中
            String emailContent = "您好，本次登录的验证码为：%s，将在10分钟之后过期";
            String emailTitle = "注册验证码";
            String message = String.format(emailContent, code);
            EmailUtil.sendMail(email, message, emailTitle);
            return true;
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        } finally {
        }
    }
}
